using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entity;
using System.Data;
using DataAccess;

namespace Business
{
    public  class ResumesBusiness
    {
        public DataTable GetResumes()
        {
            DataTable dt = new DataTable();
            string sql = "SELECT * FROM Resumes";
            dt = DA.GetDataTable(sql);
            return dt;
        }

        public int AddResume(ResumesEntity resumes)
        {
            int i = 0;
            string sql = "INSERT into [dbo].[Resumes] VALUES (@ApplicantID, @ResumeName, @ResumePath, @ResumeType, @ResumeStatus)";
            string[] paras = { "@ApplicantID", "@ResumeName", "@ResumePath", "@ResumeType", "@ResumeStatus" };
            object[] values = { resumes.ApplicantID, resumes.ResumeName, resumes.ResumePath, resumes.ResumeType, resumes.ResumeStatus };
            i = DA.ExecuteNonQuery(sql, commandType.Text, parameters, values);
            return i;
        }

        public int UpdateResume(ResumesEntity resumes)
        {
            int i = 0;
            string sql = "UPDATE [dbo].[Resumes] SET ApplicantID = @ApplicantID, ResumeName = @ResumeName, ResumePath = @ResumePath, ResumeType = @ResumeType, ResumeStatus = @ResumeStatus WHERE ResumeID = @ResumeID";
            string[] paras = { "@ApplicantID", "@ResumeName", "@ResumePath", "@ResumeType", "@ResumeStatus", "@ResumeID" };
            object[] values = { resumes.ApplicantID, resumes.ResumeName, resumes.ResumePath, resumes.ResumeType, resumes.ResumeStatus, resumes.ResumeID };
            i = DA.ExecuteNonQuery(sql, commandType.Text, parameters, values);
            return i;
        }

        public int DeleteResume(int ResumeID)
        {
            int i = 0;
            string sql = "DELETE FROM [dbo].[Resumes] WHERE ResumeID = @ResumeID";
            string[] paras = { "@ResumeID" };
            object[] values = { ResumeID };
            i = DA.ExecuteNonQuery(sql, commandType.Text, parameters, values);
            return i;
        }

        public DataTable GetResume(int ResumeID)
        {
            DataTable dt = new DataTable();
            string sql = "SELECT * FROM Resumes WHERE ResumeID = @ResumeID";
            string[] paras = { "@ResumeID" };
            object[] values = { ResumeID };
            dt = DA.GetDataTable(sql, commandType.Text, parameters, values);
            return dt;
        }
    }
}
